import React from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faEllipsisH, faCalendarAlt, faUser } from '@fortawesome/free-solid-svg-icons';
import { ProjectStatus, Priority } from '../../types/enums';

export interface ProjectCardProps {
  title: string;
  description: string;
  status: ProjectStatus;
  priority: Priority;
  startDate: string;
  endDate: string;
  createdBy: {
    id: string;
    username: string;
    email: string;
    fullName?: string;
    avatar?: string;
  };
}

export const ProjectCard: React.FC<ProjectCardProps> = ({
  title,
  description,
  status,
  priority,
  startDate,
  endDate,
  createdBy
}) => {
  const getStatusColor = (status: ProjectStatus) => {
    switch (status) {
      case ProjectStatus.ACTIVE:
        return 'bg-green-100 text-green-800';
      case ProjectStatus.COMPLETED:
        return 'bg-blue-100 text-blue-800';
      case ProjectStatus.ONHOLD:
        return 'bg-yellow-100 text-yellow-800';
      case ProjectStatus.CANCELLED:
        return 'bg-red-100 text-red-800';
      default:
        return 'bg-gray-100 text-gray-800';
    }
  };

  const getPriorityColor = (priority: Priority) => {
    switch (priority) {
      case Priority.HIGH:
        return 'text-red-600';
      case Priority.MEDIUM:
        return 'text-yellow-600';
      case Priority.LOW:
        return 'text-green-600';
      default:
        return 'text-gray-600';
    }
  };

  return (
    <div className="p-6 bg-white rounded-lg border border-gray-100 hover:shadow-md transition-shadow">
      <div className="flex items-center justify-between mb-4">
        <h3 className="text-lg font-semibold text-gray-900">{title}</h3>
        <div className="flex items-center space-x-2">
          <span className={`px-2 py-1 rounded-full text-xs font-medium ${getStatusColor(status)}`}>
            {status}
          </span>
          <button className="text-gray-400 hover:text-gray-600">
            <FontAwesomeIcon icon={faEllipsisH} />
          </button>
        </div>
      </div>
      <p className="text-gray-600 mb-4">{description}</p>
      <div className="flex items-center justify-between mb-4">
        <div className="flex items-center space-x-4">
          <div className="flex items-center text-gray-600">
            <FontAwesomeIcon icon={faCalendarAlt} className="mr-2" />
            <span className="text-sm">{new Date(startDate).toLocaleDateString()}</span>
          </div>
          <div className={`font-medium ${getPriorityColor(priority)}`}>
            {priority}
          </div>
        </div>
        <div className="flex items-center">
          <div className="w-8 h-8 rounded-full bg-warm-light/20 flex items-center justify-center">
            {createdBy.avatar ? (
              <img
                src={createdBy.avatar}
                alt={createdBy.username}
                className="w-8 h-8 rounded-full"
              />
            ) : (
              <FontAwesomeIcon icon={faUser} className="text-warm-DEFAULT" />
            )}
          </div>
        </div>
      </div>
    </div>
  );
}; 